package com.lagou.zuoyes1m3;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class StudentsTest {

    static StudentsFunction studentsFunction = new StudentsFunction();

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        //创建ArrayList集合存储信息
        List<Students> list = new ArrayList<>();

        System.out.println("==欢迎登录学生管理系统==");
        //判断是否结束循环
        boolean flag = true;
        while (flag) {
            System.out.println("  请选择要实现的功能：");
            System.out.print("1:添加学生   ");
            System.out.println("2:删除学生");
            System.out.print("3:修改学生   ");
            System.out.println("4:查找学生");
            System.out.print("5:遍历学生   ");
            System.out.println("6:退出系统");

            String str = scanner.next();

            //switch循环判断用户输入的是什么信息
            switch (str) {
                case "1":
                    studentsFunction.add(list);
                    break;
                case "2":
                    studentsFunction.delete(list);
                    break;
                case "3":
                    Students update = studentsFunction.update(list);
                    if (update != null) {
                        System.out.println("修改后的信息为：" + update);
                    }
                    break;
                case "4":
                    Students byId = studentsFunction.findById(list);
                    if (byId != null) {
                        System.out.println("您查找的信息为：" + byId);
                    }
                    break;
                case "5":
                    studentsFunction.findAll(list);
                    break;
                case "6":
                    scanner.close();
                    flag = false;
                    break;
                default:
                    break;
            }
            System.out.println();
        }
        System.out.println("您已退出！");
    }
}
